package com.hjxr.xmgl.web.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.xmgl.web.domain.QuotaTableDataFunction;
import com.hjxr.xmgl.web.service.IQuotaTableDataFunctionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;


/**
 * 数据函数注册运算Controller
 *
 * @author hjxr
 * @date 2021-12-02
 */
@RestController
@RequestMapping("/system/function")
public class QuotaTableDataFunctionController extends BaseController
{
    @Autowired
    private IQuotaTableDataFunctionService quotaTableDataFunctionService;

    /**
     * 查询数据函数注册运算列表
     */
    @PreAuthorize("@ss.hasPermi('system:function:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuotaTableDataFunction quotaTableDataFunction)
    {
        startPage();
        List<QuotaTableDataFunction> list = quotaTableDataFunctionService.selectQuotaTableDataFunctionList(quotaTableDataFunction);
        return getDataTable(list);
    }

    /**
     * 导出数据函数注册运算列表
     */
    @PreAuthorize("@ss.hasPermi('system:function:export')")
    @Log(title = "数据函数注册运算", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QuotaTableDataFunction quotaTableDataFunction)
    {
        List<QuotaTableDataFunction> list = quotaTableDataFunctionService.selectQuotaTableDataFunctionList(quotaTableDataFunction);
        ExcelUtil<QuotaTableDataFunction> util = new ExcelUtil<QuotaTableDataFunction>(QuotaTableDataFunction.class);
        return util.exportExcel(list, "function");
    }

    /**
     * 获取数据函数注册运算详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:function:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(quotaTableDataFunctionService.selectQuotaTableDataFunctionById(id));
    }

    /**
     * 新增数据函数注册运算
     */
    @PreAuthorize("@ss.hasPermi('system:function:add')")
    @Log(title = "数据函数注册运算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuotaTableDataFunction quotaTableDataFunction)
    {
        return toAjax(quotaTableDataFunctionService.insertQuotaTableDataFunction(quotaTableDataFunction));
    }

    /**
     * 修改数据函数注册运算
     */
    @PreAuthorize("@ss.hasPermi('system:function:edit')")
    @Log(title = "数据函数注册运算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuotaTableDataFunction quotaTableDataFunction)
    {
        return toAjax(quotaTableDataFunctionService.updateQuotaTableDataFunction(quotaTableDataFunction));
    }

    /**
     * 删除数据函数注册运算
     */
    @PreAuthorize("@ss.hasPermi('system:function:remove')")
    @Log(title = "数据函数注册运算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(quotaTableDataFunctionService.deleteQuotaTableDataFunctionByIds(ids));
    }
}
